package com.example.sharpshopdemo.controller;

import com.example.sharpshopdemo.entity.Power;
import com.example.sharpshopdemo.entity.Result;
import com.example.sharpshopdemo.service.PowerService;
import com.example.sharpshopdemo.service.RoleService;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/power")
@CrossOrigin
public class PowerController {
   @Autowired
   private PowerService service;

    @GetMapping("/list")
    public Result list(){
        return service.getAll();
    }

    @PostMapping("/add")
    @Operation(summary = "添加用户")
    public Power insertData(Power power){
        return new Power();
    }

    @PostMapping("/update")
    @Operation(summary = "更新数据")
    public Power updateDate(Power power){
        return new Power();
    }

    @PostMapping("/delete")
    @Operation(summary = "删除数据")
    public Power deleteDate(Power power){
        return new Power();
    }
    @Autowired
    private RoleService roleService;

    // 模糊查询端点
    @GetMapping("/powers/name-like")
    public Result<List<Power>> findPowersByNameLike(@RequestParam String keyword) {
        return PowerService.findPowersByNameLike(keyword);
    }

}
